package com.cn.kabalifemerchants.ui.order.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cn.kabalifemerchants.R;
import com.cn.kabalifemerchants.ui.order.bean.OrderListListBean;
import com.cn.kabalifemerchants.utils.GlideUtil;

import java.util.List;

/**
 * Created by 晓林 on 2020/10/20.
 * function:
 */
public class OrderAdapter extends BaseQuickAdapter<OrderListListBean.ResultBean.DataBean, BaseViewHolder> {

    int mId;

    public OrderAdapter(int layoutResId, @Nullable List<OrderListListBean.ResultBean.DataBean> data, int mId) {
        super(layoutResId, data);
        this.mId = mId;
    }

    @Override
    protected void convert(BaseViewHolder helper, final OrderListListBean.ResultBean.DataBean item) {
        helper.setText(R.id.tv_deposit_time, item.getDeposit_time())
                .setText(R.id.tv_title, item.getTitle())
                .setText(R.id.tv_deposit, item.getDeposit())
                .setText(R.id.tv_phone, item.getPhone());
        GlideUtil.ImageLoad(this.mContext, item.getIcon(), helper.getView(R.id.good_img));
        helper.addOnClickListener(R.id.tv_btn_jiedan);
        helper.addOnClickListener(R.id.tv_btn_weikuan);
        helper.addOnClickListener(R.id.tv_btn_quxiao);
        helper.addOnClickListener(R.id.ll_btn_phone);
        helper.addOnClickListener(R.id.tv_btn_tongyi);
        helper.addOnClickListener(R.id.tv_btn_jujue);

        if (mId == 0) {
            helper.setGone(R.id.tv_btn_jiedan, true);
            helper.setGone(R.id.tv_btn_weikuan, false);
            helper.setGone(R.id.tv_btn_quxiao, false);
            helper.setVisible(R.id.ll_btn_phone, false);
            helper.setGone(R.id.tv_Start,false);
        } else if (mId == 1) {
            helper.setGone(R.id.tv_btn_jiedan, false);
            helper.setGone(R.id.tv_btn_weikuan, true);
            helper.setGone(R.id.tv_btn_quxiao, false);
            helper.setVisible(R.id.ll_btn_phone, true);
            helper.setGone(R.id.tv_Start,false);
        } else if (mId == 2) {
            helper.setGone(R.id.tv_btn_jiedan, false);
            helper.setGone(R.id.tv_btn_weikuan, false);
            helper.setGone(R.id.tv_btn_quxiao, true);
            helper.setVisible(R.id.ll_btn_phone, true);
            helper.setGone(R.id.tv_Start,false);
        } else if (mId == 3){
            helper.setGone(R.id.tv_Start,false);
            helper.setGone(R.id.tv_btn_jiedan, false);
            helper.setVisible(R.id.ll_btn_phone, true);
            helper.setGone(R.id.tv_btn_weikuan, false);
            helper.setGone(R.id.tv_btn_quxiao, false);

        }else {
            helper.setGone(R.id.tv_Start,true);
            helper.setText(R.id.tv_Start,item.getIs_tui()==1?"申请退款中":item.getIs_tui()==2?"退款成功":"退款拒绝");
            helper.setGone(R.id.tv_btn_jiedan, false);
            helper.setVisible(R.id.ll_btn_phone, false);
            helper.setGone(R.id.tv_btn_weikuan, false);
            helper.setGone(R.id.tv_btn_quxiao, false);
            if (item.getIs_tui()==1){
                helper.setGone(R.id.tv_btn_tongyi, true);
                helper.setGone(R.id.tv_btn_jujue, true);
            }else {
                helper.setGone(R.id.tv_btn_tongyi, false);
                helper.setGone(R.id.tv_btn_jujue, false);
            }

        }
    }
}
